package com.cloudpolice.equipment.service.Impl;

import com.cloudpolice.equipment.dao.EquipmentAdvertisingMapper;
import com.cloudpolice.equipment.model.EquipmentAdvertisingModel;
import com.cloudpolice.equipment.model.InPutParam.EquipmentAdvertisingSelectInParam;
import com.cloudpolice.equipment.service.EquipmentAdvertisingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：梁昊，后端工程师：flyman5，前端工程师：孙耀
 * @create 2020-04-02 12:44
 * @function
 * @editLog
 */
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Service
public class EquipmentAdvertisingServiceImpl implements EquipmentAdvertisingService {
    @Autowired
    EquipmentAdvertisingMapper equipmentAdvertisingMapper;

    /**
     * 增加门禁机广告
     *
     * @param equipmentAdvertisingModel com.cloudpolice.equipment.model.InPutParam.EquipmentAdvertisingModel
     * @return 广告列表
     */
    @Override
    public int insertEquipmentAdvertising(EquipmentAdvertisingModel equipmentAdvertisingModel) {
        final int i = equipmentAdvertisingMapper.insertEquipmentAdvertisingBeforeCheck(equipmentAdvertisingModel);
        if (i < 1)
            return equipmentAdvertisingMapper.insertEquipmentAdvertising(equipmentAdvertisingModel);
        else
            return -1;
    }

    /**
     * 修改指定门禁机广告
     *
     * @param equipmentAdvertisingModel com.cloudpolice.equipment.model.InPutParam.EquipmentAdvertisingModel
     * @return 广告列表
     */
    @Override
    public int updateEquipmentAdvertisingById(EquipmentAdvertisingModel equipmentAdvertisingModel) {
        return equipmentAdvertisingMapper.updateEquipmentAdvertisingById(equipmentAdvertisingModel);
    }

    /**
     * 删除门禁机广告
     *
     * @param equipmentAdvertisingModel com.cloudpolice.equipment.model.InPutParam.EquipmentAdvertisingModel
     * @return 影响条数
     */
    @Override
    public int deleteEquipmentAdvertisingById(EquipmentAdvertisingModel equipmentAdvertisingModel) {
        return equipmentAdvertisingMapper.deleteEquipmentAdvertisingById(equipmentAdvertisingModel);
    }

    /**
     * 得到门禁机广告
     *
     * @param equipmentAdvertisingSelectInParam 得到门禁机广告
     * @return 广告列表
     */
    @Override
    public List<EquipmentAdvertisingModel> selectEquipmentAdvertising(EquipmentAdvertisingSelectInParam equipmentAdvertisingSelectInParam) {
        return equipmentAdvertisingMapper.selectEquipmentAdvertising(equipmentAdvertisingSelectInParam);
    }
}
